package com.gzhuxj201.service.Impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.gzhuxj201.entity.PageBean;
import com.gzhuxj201.entity.StuFile;
import com.gzhuxj201.mapper.StuFileMapper;
import com.gzhuxj201.service.StuFileService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class StuFileServiceImpl implements StuFileService {
    @Autowired
    private StuFileMapper stuFileMapper;

    @Override
    public PageBean page(Integer page, Integer pageSize, String tno,Integer homeWorkId,String sno,String studentName) {
        PageHelper.startPage(page,pageSize);
        List<StuFile> stuFileList = stuFileMapper.page(tno,homeWorkId,sno,studentName);

        Page<StuFile> p=(Page<StuFile>)stuFileList;
        PageBean pageBean = new PageBean(p.getTotal(), p.getResult());

        return pageBean;
    }

    @Override
    public int add(StuFile stuFile) {
        return stuFileMapper.add(stuFile);
    }

    @Override
    public StuFile selectByHomeWorkIdAndSno(Integer homeWorkId, String sno) {
        return stuFileMapper.selectByHomeWorkIdAndSno(homeWorkId,sno);
    }
}
